package interfaceSegregationPrinciple

/**
 * 接口隔离原则
 *
 * 模拟一个电子商务系统，有三个角色
 * 1.门户，只能查询
 * 2.外部系统，只用添加订单的功能
 * 3.管理平台，有增加，删除，修改，查询功能
 *
 * 通过获取不同的抽象实例，达到方法隔离的目的
 */
fun main() {
    val order = Order()

    /**
     * 获取不同的对象
     */
    val iOrderForPortal = order.getOrderForPortal()
    val iOrderForOtherSys = order.getOrderForSys()
    val iOrderForAdmin = order.getOrderForAdmin()

    iOrderForPortal.getOrder("OrderForPortal\n")

    iOrderForOtherSys.insertOrder("OrderForOtherSys\n")

    iOrderForAdmin.getOrder("OrderForAdmin")
    iOrderForAdmin.insertOrder("OrderForAdmin")
    iOrderForAdmin.removeOrder("OrderForAdmin")
    iOrderForAdmin.updateOrder("newOrderForAdmin", "OrderForAdmin")
}